﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace GISforTT_API
{
    public class MapLayerDef
    {
        public enum MapLayerType
        {
            StreetMap,
            SatelliteImagery,
            ShadedRelief,
            OnlinePublishedMap,
            OnlinePointAnnotationsLayer,
            OnlineLineAnnotationsLayer,
            OnlinePolygonAnnotationsLayer,
            OfflineAnnotationLayer
        };

        #region properties

        public MapLayerType LayerType { get; set; }
        public string LayerID { get; set; }
        public string LayerURL { get; set; }

        #endregion


        /// <summary>
        /// Defines a Map layer to be added to the layers manager
        /// </summary>
        /// <param name="type"></param>
        public MapLayerDef(MapLayerType type)
        {
            LayerType = type;
            InitializePredefinedLayers();
        }

        /// <summary>
        /// Defines a map layer to be added to the layers manager
        /// </summary>
        /// <param name="type">the type of the layer</param>
        /// <param name="url">the url of the layer if it is an online annotations layer</param>
        public MapLayerDef(MapLayerType type, string url)
        {
            LayerType = type;
            LayerURL = url;

            InitializePredefinedLayers();
        }


        /// <summary>
        /// Defines a map layer to be added to the layers manager
        /// </summary>
        /// <param name="type">the type of the layer</param>
        /// <param name="id">a string represeting the unique ID/name of the layer</param>
        /// <param name="url">the url of the layer if it is an online published layer or an online annotations layer</param>
        public MapLayerDef(MapLayerType type, string id, string url)
        {
            LayerType = type;
            LayerID = id;
            LayerURL = url;

            InitializePredefinedLayers();
        }


        private void InitializePredefinedLayers()
        {
            switch (LayerType)
            {
                case MapLayerType.StreetMap:
                    LayerID = "StreetMap";
                    LayerURL = "http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer";
                    break;
                case MapLayerType.ShadedRelief:
                    LayerID = "ShadedRelief";
                    LayerURL = "http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_ShadedRelief_World_2D/MapServer";
                    break;
                case MapLayerType.SatelliteImagery:
                    LayerID = "Imagery";
                    LayerURL = "http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_Imagery_World_2D/MapServer";
                    break;
                case MapLayerType.OfflineAnnotationLayer:
                    LayerID = "AnnotationsLayer";
                    break;
                case MapLayerType.OnlinePointAnnotationsLayer:
                    LayerID = "PointAnnotationsLayer";                    
                    break;
                case MapLayerType.OnlinePolygonAnnotationsLayer:
                    LayerID = "PolygonAnnotationsLayer";
                    break;
                case MapLayerType.OnlineLineAnnotationsLayer:
                    LayerID = "LineAnnotationsLayer";                    
                    break;                    
            }
        }


    }
}
